﻿using System;
using System.Windows.Forms;
using System.Drawing;
using System.ComponentModel;

using xEngine.Debugging;

namespace xEditor.UI
{
    public class DarkMenuStrip : MenuStrip
    {
        #region Member Variables
        #endregion

        #region Properties

        //[Category("Appearance")]
        //[Description("")]

        #endregion

        #region Constructors

        public DarkMenuStrip()
        {
            Renderer = new CMSR();
        }

        #endregion

        #region Functions
        #endregion

        private class CMSR : ToolStripRenderer
        {
            protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e)
            {
                Rectangle borders = e.AffectedBounds;
                borders.Width--;
                borders.Height--;

                e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(64, 64, 64)), e.AffectedBounds);
    
                if(!typeof(DarkMenuStrip).IsInstanceOfType(e.ToolStrip))
                    e.Graphics.DrawRectangle(new Pen(Color.FromArgb(45, 45, 45)), borders);
            }

            protected override void OnRenderSeparator(ToolStripSeparatorRenderEventArgs e)
            {
                Rectangle bounds = new Rectangle(Point.Empty, e.Item.Size);

                int y = bounds.Bottom / 2;
                int margin = 8;

                e.Graphics.DrawLine(new Pen(Color.FromArgb(44, 44, 44)), bounds.Left + margin, y, bounds.Right - margin, y);
            }
        }
    }
}
